package org.autumn.algorithm;

public class BinaryPrint {

    public static void print(int num) {
        // 0000 0000 0000 0000 0000 0000 0000 0001
        int count = 0;
        for (int i = 31; i >= 0; i--) {
            System.out.print((num & 1 << i) == 0 ? "0" : "1");
            count++;
            if (count % 4 == 0){
                System.out.print(" ");
            }
        }
        System.out.println();
    }

    public static void main(String[] args) {
        print(4);
        print(8);
        print(4 & 8);
        print(4 | 8);
        print(4 ^ 8);
        System.out.println(~Integer.MIN_VALUE +1);

    }
}
